package com.liankuan.console.common;

import com.fasterxml.jackson.annotation.JsonInclude;

import java.io.Serializable;

/**
 * @author bobo
 */
@JsonInclude
public class BaseRsp<T> implements Serializable {

    private static final long serialVersionUID = -4185151304730685014L;

    private int code = -1;
    private String msg = "";
    private T data = null;

    public BaseRsp(T data) {
        this.code = ResultEnum.SUCCESS.getState();
        this.data = data;
    }

    public BaseRsp(ResultEnum resultEnum) {
        this.code = resultEnum.getState();
        this.msg = resultEnum.getMsg();
    }

    public BaseRsp(ResultEnum resultEnum, T data) {
        this.code = resultEnum.getState();
        this.msg = resultEnum.getMsg();
        this.data = data;
    }

    public BaseRsp(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getMsg() {
        return msg;
    }

    @Override
    public String toString() {
        return "BaseRsp [code=" + code + ", data=" + data + ", msg=" + msg + "]";
    }

}
